﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using SYcwpb.Helpers;

namespace SYcwpb.Models
{
    class DutyInfoModel
    {
        public string UserID { get; set; }
        public string UserName { get; set; }
        public string PlanAtten { get; set; }
        public string PlanOut { get; set; }

        private string _actualAtten;
        public string ActualAtten
        {
            get { return _actualAtten; }
            set { 
                _actualAtten = value;
                SetDelayForeground();
            }

        }
        public string Place { get; set; }
        public string Reptrain { get; set; }
        public string OutTime { get; set; }

        private string _class;
        public string _Class
        {
            get { return _class; }
            set
            {
                if (_class == value)
                    return;
                _class = value;
                SetBackGround();
            }
        }
        public string PbyInfo { get; set; }
        public string DTQ { get; set; }
        public Brush DelayForeground { get; set; }

        public Brush ClassForeground { get; set; }

        public DutyInfoModel() { DelayForeground = Brushes.Black; }

        public void SetDelayForeground()
        {
            if (string.IsNullOrEmpty(PlanAtten))
                return;

            int intPlan = GlobalVariables.FormatTimeToInt(PlanAtten);
            int intAcual = GlobalVariables.FormatTimeToInt(ActualAtten);

            if (ActualAtten.CompareTo(PlanAtten) > 0)
            {
                if (intAcual > intPlan + CONSTDATA.DelayInter * 60)
                {
                    DelayForeground = Brushes.Red;
                }
                else
                    DelayForeground = Brushes.Orange;
            }
        }

        public void SetBackGround()
        {
            switch (_class)
            {
                case "0":
                    this.ClassForeground = Brushes.LightYellow;
                    break;
                case "2":
                    this.ClassForeground = Brushes.Orange;
                    break;
                case "3":
                    this.ClassForeground = Brushes.Blue;
                    break;
            }
            
        }
    }

    class AttenInfoMedel
    {
        public string UserID { get; set; }

        public string UserName { get; set; }

        public string Action { get; set; }

        public string TimeInfo { get; set; }

    }
}
